<?php
namespace app\home\controller;

use \app\common\controller\Homebase;
use \think\Loader;

class Setting extends Basic
{
    public function _initialize()
    {
        /**
         * 基本设置三级导航
         */
        $this->menu_base[0]['text'] = '基本信息';
        $this->menu_base[0]['url']  = 'site';
        $this->menu_base[1]['text'] = 'SEO信息';
        $this->menu_base[1]['url']  = 'seo';
        $this->options              = Loader::model('Options');
        // $this->menu_base[2]['text'] = '短信API配置';
        // $this->menu_base[2]['url']  = 'smsapi';
        // $this->menu_base[3]['text'] = '微信配置';
        // $this->menu_base[3]['url']  = 'wxset';
    }
    /**
     * 站点基本设置
     * @return [type] [description]
     */
    public function site()
    {
        if (IS_POST) {
            $res = $this->options->saveOptions('site_options',input('')['options'],1);
            if($res){
                return $this->ret->setCode(0)->setMsg('配置更新成功')->toJson();
            }else{
                return $this->ret->setCode(1)->setMsg($res)->toJson();
            }
        }
        $this->assign('third_menu', $this->menu_base);
        return $this->fetch();
    }
    public function seo()
    {
        if (IS_POST) {
            $res = $this->options->saveOptions('seo_options',input('')['options'],1);
            if($res){
                return $this->ret->setCode(0)->setMsg('配置更新成功')->toJson();
            }else{
                return $this->ret->setCode(1)->setMsg($res)->toJson();
            }
        }
        $this->assign('third_menu', $this->menu_base);
        return $this->fetch();
    }
    public function wxset()
    {
        $this->assign('third_menu', $this->menu_base);
        return $this->fetch();
    }
    public function smsapi()
    {
        $this->assign('third_menu', $this->menu_base);
        return $this->fetch();
    }

}
